<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        var cSet = new Set();
        function f_shuaxin() {
            var weishuid = document.getElementById("weishuid");
            var weishuid_number = +weishuid.value;
            if(weishuid_number == 0) {
                alert('请设置生成位数');
                return;
            }
            //var isShuaXin = confirm("是否确认新刷？");
            //if(!isShuaXin) return;
            cSet.clear();
            var bixuanhaoid = document.getElementById("bixuanhaoid");
            var buxuanhaoid = document.getElementById("buxuanhaoid");

            if(+bixuanhaoid.value > 0) cSet.add(+bixuanhaoid.value);
            while(true) {
                if(cSet.size >= weishuid_number) break;
	let r = Math.floor(Math.random()*10) + 1;
	if(r == +buxuanhaoid.value) continue;
                cSet.add(r);
            }
           document.getElementById("spanid").innerHTML = Array.from(cSet)
           .sort(function(a, b){return a-b})
           .join(",");
        }

        function num(t){
            if(isNaN(+t.value)) {
	document.getElementById("bixuanhaoid").value = '';
	document.getElementById("buxuanhaoid").value = '';
	}
            document.getElementById("bixuanhaoid").value = +t.value;
        }
    </script>

    <style>
        #div1{
            color: red;
            margin: 10% auto;
            /* border: 1px red solid; */
            text-align: center;
        }
   
     
    </style>
</head>
<body>
        <div id="div1">
            <span id="spanid">0</span>
            <br/><br/>
            必生号：<input type="number" min="1" max="10" placeholder="必生号" id="bixuanhaoid"/><br/><br/>
            不生号：<input type="number" min="1" max="10" placeholder="必生号" id="buxuanhaoid"/>
            <br/><br/>
            生成位：<input type="number" min="1" max="10" placeholder="生成多少位?" id="weishuid" value="5"/>
            <br/><br/>
            <!-- 
            <input type="button" value="1" onclick="num(this)"/>
            <input type="button" value="2" onclick="num(this)"/>
            <input type="button" value="3" onclick="num(this)"/>
            <input type="button" value="4" onclick="num(this)"/>
            <input type="button" value="5" onclick="num(this)"/>
            <input type="button" value="6" onclick="num(this)"/>
            <input type="button" value="7" onclick="num(this)"/>
            <input type="button" value="8" onclick="num(this)"/>
            <input type="button" value="9" onclick="num(this)"/>
            <input type="button" value="10" onclick="num(this)"/>-->
            <input type="button" value="清空" onclick="num(this)"/>
            <br/><br/> 
            <input type="button" value="刷新" onclick="f_shuaxin()">
        </div>

        
        
</body>
</html>